This invention relates to novel penicillin and cephlosporin derivatives and non-toxic salts thereof represented by the formula (I), ##STR3## wherein Ar represents a phenyl or heterocyclic group which may be substituted by a halogen atom, or a hydroxy or lower alkoxy group, R represents a hydrogen atom or a hydroxy group, X represents CH or N, ##STR4## 1 and n are integers of 0 or 1 wherein the sum equal to 1 and n is 0 or 1, and m is an integer equal to 1 or 2.